package com.eastfair.builder.service.impl;

import com.eastfair.builder.service.BuilderBuilderRepairReportService;
import com.eastfair.core.base.R;
import com.eastfair.core.exception.BizException;
import com.eastfair.home.api.BuilderRepairReportFeign;
import com.eastfair.home.dto.BuilderRepairReportDTO;
import com.eastfair.home.vo.BuilderRepairReportVO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 搭建商报修服务.
 *
 * @author dqq
 * @date 2023 /6/30
 */
@Service
@Slf4j
public class BuilderBuilderRepairReportServiceImpl implements BuilderBuilderRepairReportService {

    @Resource
    private BuilderRepairReportFeign builderRepairReportFeign;

    @Override
    public List<BuilderRepairReportVO> queryBuilderRepairReportList(BuilderRepairReportDTO query) {
        log.info("queryBuilderRepairReportList - 查询搭建商报修申请列表VO, query={}", query);
        R<List<BuilderRepairReportVO>> result = builderRepairReportFeign.queryBuilderRepairReportList(query);
        log.info("queryBuilderRepairReportList - 查询搭建商报修申请列表VO, result={}", result);
        if (!result.getIsSuccess()) {
            throw BizException.wrap(result.getCode(), result.getMsg());
        }
        return result.getData();
    }

    @Override
    public List<BuilderRepairReportVO> queryByExhibitor(Long exhibitionManageId, Long companyId, String spaceCode, String siteName) {
        BuilderRepairReportDTO query = new BuilderRepairReportDTO();
        query.setExhibitionManageId(exhibitionManageId);
        query.setCompanyId(companyId);
        query.setSpaceCode(spaceCode);
        query.setSiteName(siteName);
        return queryBuilderRepairReportList(query);
    }
}